﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace ShenRuQianChuChapt11Template
{
    /// <summary>
    /// DataTemplateWindow.xaml 的交互逻辑
    /// </summary>
    public partial class DataTemplateWindow : Window
    {
        public DataTemplateWindow()
        {
            InitializeComponent();
            InitalCarList();
        }

        //初始化ListBox
        private void InitalCarList()
        {
            List<Car> carlist = new List<Car>()
            {
                new Car(){ Automaker="Lamborghini",Name="Aventador",Year="1990",TopSpeed="340"},
                new Car(){ Automaker="Lamborghini",Name="Gallardo",Year="2001",TopSpeed="353"},
                new Car(){ Automaker="Lamborghini",Name="Huracan",Year="2003",TopSpeed="325"},
                new Car(){ Automaker="Lamborghini",Name="Reventon",Year="2010",TopSpeed="340"},
            };

            //填充数据源
            this.listBoxCars.ItemsSource = carlist;

        }

       
       
    }
}
